package com.ctshk.rpc.payment.dto.req.unionpay;

import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @BelongsProject: ctshk-cloud
 * @BelongsPackage: com.ctshk.rpc.payment.dto.req.unionpay
 * @Author: hef
 * @CreateTime: 2021-04-28 15:34
 * @Description: 描述
 */
@Data
public class UnionPayTransReq extends UnionPayCommonReq {
    /**
     * 渠道类型，07-PC，08-手机
     */
    private String channelType;
    /**
     * 前台通知地址 ，控件接入方式无作用
     */
    private String frontUrl;
    /**
     * 后台通知地址
     */
    private String backUrl;
    /**
     * 订单金额
     * 单位 分
     */
    private String txnAmt;
    /**
     * 交易币种
     */
    private String currencyCode;

    public UnionPayTransReq(String channelType, String backUrl, String merId, String orderId,
                            LocalDateTime txnTime, BigDecimal txnAmt, String currencyCode,String frontUrl) {
        super("000201", "01", "01", merId, orderId,
                txnTime.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")));
        this.channelType = channelType;
        this.backUrl = backUrl;
        this.txnAmt = String.valueOf(txnAmt.multiply(BigDecimal.valueOf(100)).intValue());
        this.currencyCode = currencyCode;
        this.frontUrl = frontUrl;
    }
}
